<layout name="master"/>
<ul class="breadcrumb no-border no-radius b-b b-light pull-in">
    <li><a href="index.html"><i class="fa fa-home"></i> 首页</a></li>
    <li><a href="#">商品管理</a></li>
    <li><a href="#">添加品牌</a></li>
</ul>
<div class="m-b-md">
    <h3 class="m-b-none">添加品牌</h3>
</div>
<div class="row">
    <div class="col-sm-12">
        <section class="panel panel-default">
            <header class="panel-heading font-bold">添加品牌</header>
            <div class="panel-body">
                <form action="" method="POST" class="form-horizontal" role="form">

                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">品牌名称</label>
                        <div class="col-sm-4">
                            <input type="text" name="bname" class="form-control" value="<?php echo $editData['bname']?>">
                        </div>
                    </div>
                    <script src="__ROOT__/node_modules/hdjs/js/jquery.min.js"></script>
                    <script src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
                    <link rel="stylesheet" href="__PUBLIC__/uploadify/uploadify.css">
                    <style>
                        li{
                            list-style: none;
                        }
                    </style>
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label ">LOGO</label>
                        <div class="col-sm-4" id="detailPic">
                            <input type="file" name="logo" id="detail-pic" />
                            <script>
                                $(function() {
                                    $("#detail-pic").uploadify({
                                        'height'        : 30,//宽度
                                        'swf'           : '__PUBLIC__/uploadify/uploadify.swf',
                                        'uploader'      : "{:U('Admin/BrandLogo/ajaxUpload')}",//上传类
                                        'width'         : 120,//长度
                                        'buttonText' : '请选择1个图片文件',//上传文件名称
                                        'successTimeout' : 30,//成功后停留时间
                                        'fileSizeLimit' : '2000KB',//允许上传文件大小
                                        'uploadLimit' : 1,//上传数量上限
                                        'removeTimeout' : 0.2,//上传成功后停留时间
                                        'fileTypeExts' : '*.gif; *.jpg; *.png',//允许上传文件类型
                                        'onUploadSuccess' : function(file, data, response) {
                                            var li = '<li path="'+data+'" style="float: right"><img src="__ROOT__/'+data+'" style="width: 80px"/><a href="javascript:;" style="color:red" class="del-img">X</a><input name="detailPic[]" hidden value="'+data+'"/></li>';
                                            $('#detailPic').append(li);
                                        }
                                    });
                                });
                            </script>
                            <li path="<?php echo $editData['logo'] ?>" style="float: right"><img src="__ROOT__/<?php echo $editData['logo']?>" style="width: 80px" alt=""/><a href="javascript:;" style="color:red" class="del-img">X</a><input name="detailPic[]" hidden value="<?php echo $editData['logo']?>" /></li>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">排序</label>
                        <div class="col-sm-4">
                            <input type="text" name="sort" class="form-control" value="<?php echo $editData['sort']?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">是否热门</label>
                        <div class="col-sm-4">
                            是
                            <input type="radio" <?php if($editData['ishot']==1){?>checked<?php }?> name="ishot"  value="1" >

                            否
                            <input type="radio" <?php if($editData['ishot']==0){?>checked<?php }?> name="ishot"  value="0" >
                        </div>
                    </div>

                    <script src="__PUBLIC__/ueditor1_4_3/ueditor.config.js"></script>
                    <script src="__PUBLIC__/ueditor1_4_3/ueditor.all.js"></script>
                    <script src="__PUBLIC__/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>


                    <div class="form-group">
                        <div class="col-sm-10 col-sm-offset-2">
                            <button type="submit" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </form>

            </div>
        </section>
    </div>
</div>
<script>
    function controller($scope, $, _) {
        //点击删除上传图片
        $('#detailPic,#listPic').delegate('.del-img','click',function(){
            var path = $(this).parents('li').attr('path');
            var _this = $(this);
            $.post("{:u('Admin/BrandLogo/ajaxDelImg')}",{path:path},function(res){
                _this.parents('li').remove();
            })
        })
    }
</script>
